<%@	page import ="java.util.ArrayList" %>
<%@	page import ="java.util.Iterator" %>
<%@	page import ="java.util.List" %>
<%@	page import ="com.adisi.objetos.Perfil" %>


<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<jsp:directive.include file="headerComun.jsp" />
<body>
<script type="text/javascript">
//<![CDATA[
$(window).load(function(){
    $('form').validate({
        rules: {
        	perfil_nombre:{
        		alphanumeric:true,
        		required:true
        	}  
        },
        highlight: function(element) {
            $(element).closest('.form-group').addClass('has-error');
        },
        unhighlight: function(element) {
            $(element).closest('.form-group').removeClass('has-error');
        },
        errorElement: 'span',
        errorClass: 'help-block',
        errorPlacement: function(error, element) {
            if(element.parent('.input-group').length) {
                error.insertAfter(element.parent());
            } else {
                error.insertAfter(element);
            }
        }
    });

});//]]>  
</script>
<div class="container">
	<jsp:directive.include file="menuNavegacion.jsp" />
	<% 
		String msg = (String)request.getAttribute("msg");
		String msgType = (String)request.getAttribute("msg_type");
		
		if(msgType==null) msgType = "default";
		if(msg!=null) { 
	%>
	<script type="text/javascript">
	$(document).ready(function(){
		$('#alert_placeholder').append('<div class="alert alert-<%=msgType %> fade in"><button type="button" class="close" data-dismiss="alert">&times;</button><%=msg%></div>');
    	alertTimeout(3000);
	});	
    </script>
	<% } %>		
	
	<div class="row clearfix">
		<div class="col-md-4 column col-md-offset-3">
			<h3>Perfil </h3>
			
		</div>
	</div>
	<div class="row clearfix">
		<div class="col-md-6 column col-md-offset-3">
			<%
				Perfil perfil = (Perfil)request.getAttribute("perfil");
			
				String accion = (String)request.getAttribute("accion");
			
			%>	
			<form role="form" action="perfil" method="post" name="formulario">
				<div class="form-group" style="display:hidden">
					<input type="hidden" id="perfil_id" name="perfil_id" value="<%=perfil.getIdPerfil()%>">
					<input type="hidden" id="perfil_accion" name="perfil_accion" value="<%=accion%>">
				</div>			
				<div class="form-group">
					<label for="perfil_nombre">Nombre</label>
					<input type="text" class="form-control" id="perfil_nombre" name="perfil_nombre"	placeholder="Nombre del perfil" value="<%=perfil.getNombrePerfil()%>">
				</div>
				<div class="form-group">
					<label for="perfil_detalle">Detalle</label>
					<textarea type="text" class="form-control" id="perfil_detalle" name="perfil_detalle"	placeholder="Descripcion del perfil"><%=perfil.getDetallePerfil()%></textarea>
				</div>
				
				<% if(accion.equalsIgnoreCase("editar") || accion.equalsIgnoreCase("agregar")) { %>
				<button type="submit" class="btn btn-primary glyphicon glyphicon-floppy-save"> Grabar</button>
				<% } else if(accion.equalsIgnoreCase("borrar")) { %>				
				<button type="submit" class="btn btn-danger glyphicon glyphicon-trash" value="Borrar" onclick="return confirm('Esta seguro?')"> Borrar</button>
				<% } %>
				<a  href="perfil?lst" type="cancel" class="btn btn-warning glyphicon glyphicon-ban-circle"> Cancelar</a>
				
			</form>

		</div>
	</div>
</div>

</body>
</html>